<template>
	<view class="content">
		<view class="line">
			<view class="titile" @click="goback">
				<image src="/static/icon_return.png" mode=""></image>
			</view>
			<view class=""> 我的银行卡 </view>
			<view> 添加 </view>
		</view>

		<!-- 下方的列表 -->
		<u-swipe-action :show="item.show" :index="index" v-for="(item, index) in list" :key="item.id" @click="click"
			@open="open" :options="options">
			<view class="item u-border-bottom">
				<view class="">
					<image mode="aspectFill" src="/static/banklogo.png" />
				</view>
				<!-- 此层wrap在此为必写的，否则可能会出现标题定位错误 -->
				<view class="title-wrap">
					<view class="idcardTitle">
						中国银行
					</view>
					<view class="idcardDesc">
						尾号7554储蓄卡
					</view>
				</view>
			</view>
		</u-swipe-action>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				list: [{
						id: 1,
						title: '长安回望绣成堆，山顶千门次第开，一骑红尘妃子笑，无人知是荔枝来',
						images: 'https://cdn.uviewui.com/uview/common/logo.png',
						show: false
					},
					{
						id: 2,
						title: '新丰绿树起黄埃，数骑渔阳探使回，霓裳一曲千峰上，舞破中原始下来',
						images: 'https://cdn.uviewui.com/uview/common/logo.png',
						show: false
					},
					{
						id: 3,
						title: '登临送目，正故国晚秋，天气初肃。千里澄江似练，翠峰如簇',
						images: 'https://cdn.uviewui.com/uview/common/logo.png',
						show: false,
					}
				],
				options: [{
					text: '解绑',
					style: {
						backgroundColor: '#DB1414',
						// textAlign: 'center',
						height: '141rpx',
					}
				}]
			};
		},
		methods: {
			goback() {
				uni.navigateBack();
			},
			// 第1个为索引值，点击的脚标
			click(index, index1) {
				this.$u.toast(`解绑成功`);
				this.list.splice(index, 1)
			},
			// 如果打开一个的时候，不需要关闭其他，则无需实现本方法
			open(index) {
				// 先将正在被操作的swipeAction标记为打开状态，否则由于props的特性限制，
				// 原本为'false'，再次设置为'false'会无效
				this.list[index].show = true;
				this.list.map((val, idx) => {
					if (index != idx) this.list[idx].show = false;
				})
			}
		},
	};
</script>

<style lang="scss" scoped>
	.content {
		background-color: #000000;
		width: 100vw;
		height: 100vh;
		box-sizing: border-box;

		.line {

			padding-left: 23rpx;
			padding-right: 23rpx;
			height: 100rpx;
			display: flex;
			justify-content: space-between;
			align-items: center;
			font-size: 32rpx;
			font-family: PingFang SC;
			font-weight: 500;
			color: #ffffff;
			border-bottom: 3rpx solid #272727;

			image {
				width: 22rpx;
				height: 38rpx;
			}
		}

		.item {
			display: flex;
			padding: 20rpx;
			background-color: #131313;
			height: 141rpx;
		}

		image {
			width: 56rpx;
			flex: 0 0 56rpx;
			height: 56rpx;
			margin-right: 20rpx;
			border-radius: 12rpx;
		}

		.title {
			text-align: left;
			font-size: 28rpx;
			color: $u-content-color;

		}

		.idcardTitle {
			font-size: 32rpx;
			font-family: PingFang SC;
			font-weight: 500;
			color: #FFFFFF;
		}

		.idcardDesc {
			font-size: 26rpx;
			font-family: PingFang SC;
			font-weight: 500;
			color: #AAAAAA;
		}
	}
</style>
